package org.testis.gui.mvc.model.testdesign;

import org.testis.gui.mvc.model.*;
import org.testis.gui.mvc.controller.testdesign.TestCaseController;
import java.util.HashMap;

/**
 *
 * @author Cahit Emir Erel
 */
public class TestCaseModel extends AbstractModel {

    private Boolean m_critical = false;
    private Boolean m_runAlways = true;
    private Boolean m_testCaseVisibility = false;
    private Byte m_successPercentage = new Byte("100");
    private Integer m_invocationCount = 0;
    private Integer m_threadPoolSize = 0;
    private Integer m_timeout = 0;
    private String m_description = "";
    private String m_name = "";

    public String getName() {
        return m_name;
    }

    public void setName(String name) {
        if (name == null) {
            name = "";
        }
        String oldName = m_name;
        m_name = name;
        firePropertyChange(TestCaseController.CHANGE_NAME,
                oldName,
                name);
    }

    public String getDescription() {
        return m_description;
    }

    public void setDescription(String description) {
        if (description == null) {
            description = "";
        }
        String oldDescription = m_description;
        m_description = description;
        firePropertyChange(TestCaseController.CHANGE_DESCRIPTION,
                oldDescription,
                description);
    }

    public Integer getTimeout() {
        return m_timeout;
    }

    public void setTimeout(Integer timeout) {
        if (timeout == null) {
            return;
        }
        Integer oldTimeout = m_timeout;
        m_timeout = timeout;
        firePropertyChange(TestCaseController.CHANGE_TIMEOUT,
                oldTimeout,
                timeout);
    }

    public void setTestCaseVisibility(Boolean testCaseVisibility) {
        if (testCaseVisibility == null) {
            return;
        }
        Boolean oldTestCaseVisibility = m_testCaseVisibility;
        m_testCaseVisibility = testCaseVisibility;
        firePropertyChange(TestCaseController.SHOW_ADD_TEST_CASE,
                oldTestCaseVisibility,
                testCaseVisibility);
    }

    public Boolean getTestCaseVisibility() {
        return m_testCaseVisibility;
    }

    public Boolean getRunAlways() {
        return m_runAlways;
    }

    public void setRunAlways(Boolean runAlways) {
        if (runAlways == null) {
            return;
        }
        Boolean oldRunAlways = m_runAlways;
        m_runAlways = runAlways;
        firePropertyChange(TestCaseController.CHANGE_RUN_ALWAYS,
                oldRunAlways,
                runAlways);
    }

    public Integer getThreadPoolSize() {
        return m_threadPoolSize;
    }

    public void setThreadPoolSize(Integer threadPoolSize) {
        if (threadPoolSize == null) {
            return;
        }
        Integer oldThreadPoolSize = m_threadPoolSize;
        m_threadPoolSize = threadPoolSize;
        firePropertyChange(TestCaseController.CHANGE_THREAD_POOL_SIZE,
                oldThreadPoolSize,
                threadPoolSize);
    }

    public Integer getInvocationCount() {
        return m_invocationCount;
    }

    public void setInvocationCount(Integer invocationCount) {
        if (invocationCount == null) {
            return;
        }
        Integer oldInvocationCount = m_invocationCount;
        m_invocationCount = invocationCount;
        firePropertyChange(TestCaseController.CHANGE_INVOCATION_COUNT,
                oldInvocationCount,
                invocationCount);
    }

    public Byte getSuccessPercentage() {
        return m_successPercentage;
    }

    public void setSuccessPercentage(Byte successPercentage) {
        if (successPercentage == null) {
            return;
        }
        Byte oldSuccessPercentage = m_successPercentage;
        m_successPercentage = successPercentage;
        firePropertyChange(TestCaseController.CHANGE_SUCCESS_PERCENTAGE,
                oldSuccessPercentage,
                successPercentage);
    }

    public Boolean getCritical() {
        return m_critical;
    }

    public void setCritical(Boolean critical) {
        if (critical == null) {
            return;
        }
        Boolean oldCritical = m_critical;
        m_critical = critical;
        firePropertyChange(TestCaseController.CHANGE_CRITICAL,
                oldCritical,
                critical);
    }
}
